package com.af.common;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

public class PropertiesManager {
	private static Properties prop = null;
	private String path = PropertiesManager.class.getResource("/").getPath()
			+ "af.properties";;
	private FileInputStream is = null;
	static PropertiesManager instance = null;

	public static synchronized PropertiesManager getInstance() {
		if (instance == null) {
			instance = new PropertiesManager();
		}
		return instance;
	}

	public PropertiesManager() {
		try {
			prop = new Properties();
			if (path.contains("%20") == true) {
				path = path.replaceAll("%20", " ");
			}
			is = new FileInputStream(path);
			prop.load(is);
			is.close();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public String returnValue(String key){
		return prop.getProperty(key);
	}
}
